package res

import (
	"fmt"
	"github.com/goccy/go-json"
	"github.com/sirupsen/logrus"
	"os"
)

type ErrorCode int

const (
	SettingsError ErrorCode = 1001 // 系统错误
	ParamError    ErrorCode = 1002 // 参数错误
)

var (
	ErrorMap = map[ErrorCode]string{
		SettingsError: "系统错误",
		ParamError:    "参数错误",
	}
)

const jsonFile = "./err_code.json"

// 读取json配置
func ReadJsonFile() {
	file, err := os.ReadFile(jsonFile)
	if err != nil {
		logrus.Error(Error)
		return
	}
	err = json.Unmarshal(file, &ErrorMap)
	if err != nil {
		logrus.Error(err)
		return
	}
	fmt.Println(ErrorMap)
}
